package bookstudytest.Compare.Comparable;



/**
 * @Author li.heng
 * @Date 2019/6/19 15
 * @Description: Comparable一般是使某种类具有比较的功能，实现的compareTo方法中实现具体的比较逻辑
 *  java的主数据类型的封装类和String都实现了Comparable类，可以直接使用compareTo进行比较
 *  ps：字符和字符串传进行比较时，其实是比较的ASCLL码值,返回的是两个值相减后的结果（前者减去后者）
 **/
public class Test {
    public static void main(String[] args) {
        Person person = new Person("a", 199, "male");
        Person person1 = new Person("b", 15, "female");
        Integer integer = new Integer(12);
        Character chara = new Character('a');
        Long longa = new Long(123L);
        Byte bytee = new Byte((byte)1);
        System.out.println(integer.compareTo(1));
        System.out.println(chara.compareTo('b'));
        System.out.println(longa.compareTo(132L));
        System.out.println(person.compareTo(person1));

        PersonFactory<Person> personFactory = Person::new;
        Person person2 = personFactory.create("1", 1, "2");
    }
}
